Repository navigation
Conversation
- UsersRepository takes the PasswordDefinition and sets PasswordDefinitionValidator on its MicroORM Repository: every save checks a plain password, also without UsersService - UsersService no longer takes a PasswordDefinition; it applies the repository's to the users it creates or loads
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
UsersRepository::__construct(DatabaseExecutor $executor, string $usersClass, ?PasswordDefinition $passwordDefinition = null): with a definition, it sets the password mapper on it (to tell a hash from a plain password) and installsPasswordDefinitionValidatoron its MicroORMRepository, chained to the validator the model declares. Every save checks a plain password, throughUsersService,UsersRepositoryor the MicroORMRepository, even when noUsersServicewas ever built. NewgetPasswordDefinition().UsersServiceno longer takes aPasswordDefinition(it used to install the validator as a side effect of its constructor). It applies the repository's definition to the users it creates or loads.Breaking change (see
CHANGELOG-7.0.md)Move the definition from
new UsersService(..., $loginField, $definition)tonew UsersRepository($executor, $class, $definition). A definition still passed to the service is an extra argument PHP ignores. With byjg/config, an injectedUsersRepositorybinding receives a boundPasswordDefinitionby type.Tests
PasswordUpgradeTest::testRepositorySaveChecksTheDefinitionbuilds aUsersRepositorywith a definition and noUsersService: a weak password is rejected throughUsersRepository::save()andRepository::save(). Removing the repository's wiring fails it. The service test ofTestUsersBasegives the definition to the repository. PHPUnit 186 tests and Psalm pass.